const ObjId = require('../common/ObjId');

class PostComment {
    constructor(obj) {
        this.id = obj.id;
        this.content = obj.content;
    }

    check() {
        // 验证 id
        let post = new ObjId(this, 'id');
        let flag = post.check();
        if (!flag.success) {
            return flag;
        }
        // 验证 content
        if (!this.content) {
            return { success: false, err: "评论内容不能为空" };
        }
        if (this.content.length > 50000) {
            return { success: false, err: "评论内容不能超过50000个字符" };
        }
        return { success: true };
    }
}

module.exports = PostComment;